<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../../common/tagInclude.jsp" %>
<%@ page import="org.apache.commons.lang.StringUtils,java.sql.Connection,java.sql.Statement,java.sql.ResultSet,cn.com.chec.en.dao.DBFactory" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.sql.Connection,java.sql.Statement,java.sql.ResultSet"%>
<HTML>
<HEAD>
	<base href="${basePath}"/>
	<title>数据库管理</title>
	<META http-equiv="content-type" content="text/html; charset=UTF-8">
	<LINK href="${basePath}styleAdmin/css/portalinabox.css" type="text/css" rel="stylesheet">		
	<meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
   <meta http-equiv="expires" content="0">
	<script type="text/javascript" src="${basePath}styleAdmin/js/prototype-1.6.0.3.js"></script>
	<script type="text/javascript" src="${basePath}styleAdmin/js/common.js"></script>
	<script type="text/javascript">
		function query(tblName){
			window.location = "${basePath}admin/dbTable/descTable?tblName=" + tblName ;
		}
		function dbDataOpr(itemName,flag){
			if(flag == '2'){
				if(!confirm('确定全部备份吗?')) return;
				window.location = "${basePath}admin/dbTable/dumpTable?flag=2" ;
			}
			else if(flag == '3'){
				window.location = "${basePath}admin/dbTable/schedulerPage" ;
			}
			else if(flag == '4'){
				window.location = "${basePath}admin/dbTable/exportList" ;
			}
			else{
				var all_checkbox = document.getElementsByName(itemName);
				var len = all_checkbox.length;
				if(isChecked(itemName) == false ){
					alert('至少选择一项');
				}else{
					if(!confirm('确认要备份指定数据表吗?'))return;
					var values = "";
					for(var i=0;i<len ;i++){
						if(all_checkbox[i].checked)
							values += "," + all_checkbox[i].value;
					}
					if(values.length > 1)
						values = values.substring(1);
					window.location = "${basePath}admin/dbTable/dumpTable?flag=1&tblNames=" + values ;
				}
			}
		}
	</script>
</HEAD>
<body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">
<form action="" method="get" name="myform">
<%@include file="../common/navigate.jsp" %>
<table width="96%" border="0" align="center" cellpadding="0" style="margin-top:5px;" cellspacing="0">
	<tr>
		<td valign="top">
			<!-- 搜索栏 -->
			<table width="100%" border="1" class="mainFunctionTable"  cellpadding="0" cellspacing="1">
				<tr height="25" class="pLabel">
			   		<td class="td_nwarpstyle">&nbsp;&nbsp;数据库管理</td>
			 	</tr>
			 </table>
		  </td>
	  </tr>
	  <tr>
	    <td>
			&nbsp;&nbsp;<a href="javascript:checkAll('tblName',true);">全选</a>
			&nbsp;&nbsp;<a href="javascript:checkAll('tblName',false);">全不选</a>
			&nbsp;&nbsp;[<a href="javascript:dbDataOpr('tblName','1');">选择性备份</a>]
			&nbsp;&nbsp;[<a href="javascript:dbDataOpr('tblName','2');">全部备份</a>]
			&nbsp;&nbsp;[<a href="javascript:dbDataOpr('tblName','3');">定时备份</a>]
			&nbsp;&nbsp;[<a href="javascript:dbDataOpr('tblName','4');">数据恢复</a>]
			<table width=100% border=1 class="mainFunctionTable"  cellpadding="0" cellspacing="1" id="table_channel">
				<tr height=25 class="pLabel" align="center">
					<td width="5%" class="td_nwarpstyle">标识</td>
					<td width="15%" class="td_nwarpstyle">数据表名称</td>
					<td width="10%" class="td_nwarpstyle">存储引擎</td>
					<td width="5%" class="td_nwarpstyle">自增</td>
					<td width="5%" class="td_nwarpstyle">行数</td>
					<td width="15%" class="td_nwarpstyle">创建时间</td>
					<td width="10%" class="td_nwarpstyle">编码校对</td>
					<td class="td_nwarpstyle">备注信息</td>
					<td width="10%" class="td_nwarpstyle">操作</td>
				</tr>
			</table>
			<table width=100% border=1 class="mainFunctionTable"  cellpadding="0" cellspacing="1" id="table_channel">
				<%
				boolean flag = false ;
				Connection conn = DBFactory.getInstance().getConnection();
				String showTables = "show table status" ;
				Statement stmt = conn.createStatement();
				ResultSet rs = stmt.executeQuery(showTables);
				while(rs.next()){
				%>
					<tr height="28"  class="<%=flag ? "c2" : "c1" %>">
						<td width="5%" align="Center"><input type="checkbox" name="tblName" id="tblName" value="<%=rs.getString("name")%>"/></td>
						<td width="15%" align="left"><a href="javascript:query('<%=rs.getString("name")%>');"><%=rs.getString("name")%></a></td>
						<td width="10%" align="Center"><%=rs.getString("engine")%></td>
						<td width="5%" align="Center"><%=StringUtils.isBlank(rs.getString("auto_increment")) ? "" : rs.getString("auto_increment")%></td>
						<td width="5%" align="Center"><%=rs.getString("rows")%></td>
						<td width="15%" align="Center"><%=rs.getString("create_time")%></td>
						<td width="10%" align="Center"><%=rs.getString("collation")%></td>
						<td><%=rs.getString("comment")%></td>
						<td width="10%" align=center>
							<a href="javascript:query('<%=rs.getString("name")%>');">查询</a>
						</td>
					</tr>
				<%flag = !flag ;}rs.close();stmt.close();conn.close(); %>
	  		</table>
		 </td>
	   </tr>
</table>
</form>
</body>
</HTML>